<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>添加一个或多个函数来处理SOAP请求</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.soapserver.html">« SoapServer</a></li>
      <li style="float: right;"><a href="soapserver.addsoapheader.html">SoapServer::addSoapHeader »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.soapserver.html">SoapServer</a></li>
    <li>添加一个或多个函数来处理SOAP请求</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="soapserver.addfunction" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SoapServer::addFunction</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SoapServer::addFunction</span> &mdash; <span class="dc-title">添加一个或多个函数来处理SOAP请求</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-soapserver.addfunction-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SoapServer::addFunction</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$functions</code></span>): <span class="type"><span class="type void">void</span></span></div>

  <p class="para rdfs-comment">
   为远程客户端导出一个或多个函数
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-soapserver.addfunction-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">functions</code></dt>

     <dd>

      <p class="para">
       导出一个函数，将函数名作为字符串传递给这个参数。
      </p>
      <p class="para">
       导出多个函数，将一组函数名作为数组传递。
      </p>
      <p class="para">
       导出所有函数，传递特殊常量 <strong><code>SOAP_FUNCTIONS_ALL</code></strong>.
      </p>
      <blockquote class="note"><p><strong class="note">注意</strong>: 
       <p class="para">
        <code class="parameter">functions</code> 接收的所有输入参数必须同时和WSDL文件中定义的
        顺序一样（它们不应该接收任何输出变量作为参数）并且返回一个或多个值。如果要返回多个
        值，它们必须返回一组被命名的输出参数作为数组。
       </p>
      </p></blockquote>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-soapserver.addfunction-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-soapserver.addfunction-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5341">
    <p><strong>示例 #1 <span class="function"><strong>SoapServer::addFunction()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">echoString</span><span style="color: #007700">(</span><span style="color: #0000BB">$inputString</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$inputString</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$server</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addFunction</span><span style="color: #007700">(</span><span style="color: #DD0000">"echoString"</span><span style="color: #007700">);<br /><br />function&nbsp;</span><span style="color: #0000BB">echoTwoStrings</span><span style="color: #007700">(</span><span style="color: #0000BB">$inputString1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$inputString2</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;array(</span><span style="color: #DD0000">"outputString1"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$inputString1</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"outputString2"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$inputString2</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">$server</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addFunction</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"echoString"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"echoTwoStrings"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$server</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addFunction</span><span style="color: #007700">(</span><span style="color: #0000BB">SOAP_FUNCTIONS_ALL</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-soapserver.addfunction-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><strong>SoapServer::SoapServer()</strong></span></li>
    <li class="member"><span class="methodname"><a href="soapserver.setclass.html" class="methodname" rel="rdfs-seeAlso">SoapServer::setClass()</a> - Sets the class which handles SOAP requests</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>